import Vue from 'vue'
import VueRouter from 'vue-router'
// import Detail from '@/views/Detail'
import Index from '@/views/Index'

// 安装路由为vue 的插件
Vue.use(VueRouter)

// 创建实例对象
const router = new VueRouter({
    mode: 'history',
    routes: [
        { path: '/', redirect: 'index' },
        { path: '/index', name: 'index', component: Index },
        { path: '/detail', name: 'detail', component: () => import('@/views/Detail') },
        { path: '/goods', component: () => import('@/views/Goods') },
    ]
})
 
// 解决导航重复
const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch((err) => err);
};


// 向外共享

export default router
